const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentTab:0,
    dotation:false,
    use:false,
  
    navData:[
 
        {
            text: '未支付',
            status:0
        },
        {
            text: '已支付',
            status:1
        },
        {
            text: '已过期',
            status:2
        },
      
        {
            text: '已退款',
            status:3
        },
        {
          text: '已取消',
          status:4
      },
       
       
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that=this;

  var userInfo=wx.getStorageSync('userInfo');   


     
    that.setData({
      platform:app.globalData.platform,      
       width:app.globalData.windowWidth,
      height:app.globalData.windowHeight,
      statusBarHeight:app.globalData.statusBarHeight,
      navHeight:app.globalData.navHeight,
      marginTop:app.globalData.navTitleTop,
      domain:app.globalData.domain,      
    })
  },
  switchNav(event){
    console.log(event);
    var cur = event.currentTarget.dataset.current;
       this.setData({
        currentTab: cur,
        });
        this.getList();
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.getList();
  },
  getList(){
    let that=this;
    let data=this.data;
    var open = wx.getStorageSync('open');
    var currentTab=data.currentTab;
    var navData=data.navData;
    console.log('currentTab'+currentTab);
    var status=navData[currentTab].status;
    wx.request({
      url: app.globalData.domain+'wechat/order/getList',
      data:{from:1,open_id:open.id,status:status},
      success:res=>{
        var data=res.data;
        console.log(data);
        that.setData({
          list:data.list,
          count:data.count
        })
      }
  })
},
setShow(){
  var order_show = this.data.order_show;
  this.setData({
    order_show:!order_show
  })
},
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})